﻿using K9Nano.Authorization;
using K9Nano.Domain.Entities;

namespace K9Nano.Application.Authentication;

public interface IRoleAppServiceBase<TRole>
    : ICurdAppServiceBase<TRole, RoleCreateDto, RoleEditDto, RoleDto, RoleQueryDto<TRole>>
    where TRole : RoleBase
{
    /// <summary>
    /// 获取角色拥有的权限列表
    /// </summary>
    /// <param name="roleId">角色ID</param>
    /// <returns></returns>
    Task<IEnumerable<Permission>> GetPermissionsByRoleIdAsync(long roleId, CancellationToken cancellation);

    /// <summary>
    /// 获取拥有角色的用户列表
    /// </summary>
    /// <param name="roleId">角色ID</param>
    /// <returns></returns>
    Task<IEnumerable<UserDto>> GetUsersByRoleIdAsync(long roleId, CancellationToken cancellation);

    /// <summary>
    /// 为角色添加权限
    /// </summary>
    /// <returns></returns>
    Task AddPermissionsAsync(RolePermissionEditDto dto, CancellationToken cancellation);

    /// <summary>
    /// 从角色中删除权限
    /// </summary>
    Task RemovePermissionsAsync(RolePermissionEditDto dto, CancellationToken cancellation);
}
